<template>
  <el-tree
    node-key="id"
    :props="props"
    :data="treeData"
    highlight-current
    :expand-on-click-node="false"
    :current-node-key="activeId"
    :default-expanded-keys="['1024982867475820033', '1024984540818568481','1024985257948084801']"
    @check-change="handleCheckChange"
    @node-click="onTree"
  />
</template>
<!-- <el-tree default-expand-all :data="depts" :props="defaultProps" -->
<!-- :expand-on-click-node="false" highlight-current :current-node-key="activeId" node-key="id" @node-click="onTree" /> -->
<script>
import { getTree } from '@/api/selectTree'

export default {
  data() {
    return {
      treeData: [],
      activeId: '1024985257948084801',
      props: {
        children: 'children',
        label: 'name'
      }
    }
  },
  async created() {
    const { data } = await getTree()
    const newData = JSON.parse(data)

    this.treeData = newData
    this.$emit('onTree', '1024985257948084801')
    // console.log(this.treeData)
  },
  methods: {
    handleCheckChange() {
      console.log(111)
    },
    onTree(a) {
      // console.log(a)
      this.$emit('onTree', a.id)
    }
  }
}
</script>

<style lang="scss">

</style>
